#ifndef __TICKABLE_H__
#define __TICKABLE_H__

#include <list>
#include <SDL/SDL.h>
#include "field.h"

class Tickable;

class TickableList : std::list<Tickable*> {
	public:
		TickableList(Field * map) {field = map;};
		virtual ~TickableList() {};
		void Subscribe(Tickable * ticky) {push_back(ticky);};
		void Unsubscribe(Tickable * ticky) {remove(ticky);};
		void HandleTick(unsigned time);
		void Draw(SDL_Surface * screen, unsigned time);
	private:
		Field * field;
};

class Tickable {
	public:
		Tickable (TickableList * tick_list) {tickList = tick_list; (*tickList).Subscribe(this);};
		virtual ~Tickable() {tickList->Unsubscribe(this);};
		virtual void HandleTick(Field & field, unsigned time) {};
		virtual void Draw(SDL_Surface * screen, unsigned time) {};
	private:
		TickableList * tickList;
};


#endif
